package Zshi;

public class Trafflc{
    /**
     * 交警
     */
    public String trafficpolice;
    /**
     * 司机
     */
    public String driver;
    /**
     * 红灯
     */
    public String redlight;


    public Trafflc(String trafficpolice){    //  this关键字调用其他构造方法，必须写在第一句
        this(trafficpolice,"李师傅","红灯");


    }
    public Trafflc(String trafficpolice,String driver,String redlight){      //调用
        this.trafficpolice=trafficpolice;
        this.redlight=redlight;
        this.driver=driver;


    }
    public void intro(){       //输出
        System.out.println(trafficpolice+":你好，你违反了交通规则，闯"+redlight+"了,"+driver+"；我愿意接受处罚");

    }
    public void yonghu(Trafficxitong trafficxitong){
        System.out.println(trafficpolice+":你好，你违反了交通规则，闯"+redlight+"了,这是你的"+trafficxitong.infringementnotice
                +driver+"；我愿意接受处罚");

    }
    public static void main(String[]args){
        //产生对象
        Trafflc trafflc =new Trafflc("王警官","李师傅","红灯");
        Trafficxitong trafficxitong=new Trafficxitong("罚单");

        System.out.println(trafflc);

        trafflc.yonghu(trafficxitong);
        trafflc.intro();

    }


}


